<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的收藏 - 会员中心 -{$sitename}</title>
{include file="center_include"/}
<script type="text/javascript">
		function setupLabel(){
            if($('.label-checkbox input').length) {
                $('.label-checkbox').each(function(){
                    $(this).removeClass('label-checkbox-on');
                });
                $('.label-checkbox input:checked').each(function(){
                    $(this).parent('label').addClass('label-checkbox-on');
                });
            };
            if($('.label-radio input').length) {
                $('.label-radio').each(function(){
                    $(this).removeClass('label-radio-on');
                });
                $('.label-radio input:checked').each(function(){
                    $(this).parent('label').addClass('label-radio-on');
                });
            };
        }  

		function initLabelEvent(){
			$(".user-img-list li").hover(function(){
				$(this).find(".ui-del").show();
			},function(){
				$(this).find(".ui-del").hide();
			});
			$('.label-checkbox').click(function(){
				setupLabel();
			});
			setupLabel();
		}
	</script>
</head>
<body>
{include file="center_header"/}
<!-- // i-header end -->
<div id="content" class="layout">
  <div class="ui-box ui-qire fn-clear" id="i-box">
    <div id="i-bar">
 {include file="center_nav"/} 
 {include file="center_fk"/}
    </div>
    <!-- // i-bar end -->
    <div class="i-box-cnt" id="i-cnt">
      <div id="i-favourite">
        <div class="ui-title i-tab-nav-box">
         <ul class="i-tab-nav" id="pids">
            <li class="current"><a href="{:zanpian_user_url('user/center/love',array('op'=>1))}" hidefocus="">全部</a></li>
            {volist name="catalogs" id="catalog"}
            	<li class="line"></li>
            	<li><a href="{:zanpian_user_url('user/center/love',array('op'=>1,'pid'=>$catalog['list_id'],'p'=>1))}" hidefocus="">{$catalog.list_name}<span>{$catalog.count}</span></a></li>
            {/volist}
          </ul>
        </div>
        <div class="ui-cnt">
          <ol class="user-img-list" id="xlist">
            <li class="loading"><img src="{$apicss}user/new/images/loading.gif"/>正在努力为您加载中... </li>
          </ol>
          <!-- // pic-list End -->
          <div class="user-opera fn-clear" style="margin: 15px 0px 20px; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(245, 245, 245);" id="i-do">
            <div class="check-del fn-left">
              <label class="label-checkbox" for="checkall" hidefocus="">
                <input type="checkbox" id="checkall">全选</label>
              <form action="" method="post" id="delremindform">
                <input type="hidden" value="" id="ids" name="ids">
                <a class="ui-edit ui-edit-short cleanup" href="javascript:;" data="1" id="delchecked">删除</a>
              </form>
            </div>
            <div class="loading pagess"><ul class="pagination" id="xpage" style="float:right"></ul></div>
          </div>
        </div>
      </div>
      <!-- // ui-box End -->
      <div id="i-hot-fav">
        <div class="ui-title i-tab-nav-box">
          <ul class="i-tab-nav">
            <li class="current">热门收藏</li>
          </ul>
        </div>
        <div class="ui-cnt">
          <ol class="user-img-list" id="hotremind">
          <li class="loading"><img src="{$apicss}user/new/images/loading.gif"/>正在努力为您加载中... </li>
          </ol>
          <!-- // pic-list End -->
        </div>
      </div>
      <!-- // ui-box End -->
    </div>
  </div>
  <!-- // i-cnt End -->
<script type="text/javascript">
		function pagegoo(url){
			$.ajax({ url: url,  success: function(data){
			    if(data.ajaxtxt!=''){
					$("#xlist").html(data.ajaxtxt);
					initLabelEvent();
					$("#i-do").show();
					$("#checkall").click(function(e){
						if ($(this).is(":checked")) {
							$("#xlist [name = ids[]]:checkbox").each(function () {
								$(this).attr('checked',true);
							});							 
						}else{
							$("#xlist [name = ids[]]:checkbox").each(function () {
								$(this).attr('checked',false);
							});		
						}
					});
				}else{
					$("#xlist").html('<li class="kong">当前没有收藏，您可以点击下面的收藏</li>');
					$("#i-do").hide();
				}
				$("#xpage").html(data.pages);
				$("#xpage a").click(function (e){
					pagegoo(e.target);
					return false;
				});
				$(".fav-cancel").click(function(event){
					$.showfloatdiv({
						wantclose:2,
						succdo:function(r){
							if(parseInt(r.rcode)==1){
								pagegoo("{:zanpian_user_url('user/center/love',array('op'=>1))}");
								gethot("{:zanpian_user_url('user/center/getlove')}");
								$("#pids").html(r.dhtxt);
								$("#pids a").unbind();
								$("#pids a").click(
									function (e){
										$(this).parent('li').nextAll().removeClass('current');
										$(this).parent('li').prevAll().removeClass('current');
										$(this).parent('li').addClass('current');
										pagegoo($(this).attr('href'));
										return false;
									}
								);
							}
						},txt:'确认删除?'
					});
				});
			},dataType:'json'});
			return false;				
		}
		pagegoo("{:zanpian_user_url('user/center/love',array('op'=>1))}");

		function gethot(url){
			$.ajax({ 
				url: url,  
				success: function(data){
					$("#hotremind").html(data);
					$('.fav-add').unbind();
					$('.fav-add').click(function (e){
						$.showfloatdiv({cssname:'loading'});
			    		var turl=$(this).attr('href');
						  $.get(
							turl,'',
							function(data){
								$.hidediv(data);
								if(parseInt(data.rcode)>0){
									gethot("{:zanpian_user_url('user/center/getlove')}");
									pagegoo("{:zanpian_user_url('user/center/love',array('op'=>1))}");
									$("#pids").html(data.dhtxt);
									$("#pids a").click(
										function (e){
											$(this).parent('li').nextAll().removeClass('current');
											$(this).parent('li').prevAll().removeClass('current');
											$(this).parent('li').addClass('current');
											pagegoo($(this).attr('href'));
											return false;
										}
									);
								}
							},
							'json'
						);
						return false;
					});

			},dataType:'json'});

		}

		gethot("{:zanpian_user_url('user/center/getlove',array('op'=>1))}");

		$("#pids a").click(function (e){
			$(this).parent('li').nextAll().removeClass('current');
			$(this).parent('li').prevAll().removeClass('current');
			$(this).parent('li').addClass('current');
			pagegoo($(this).attr('href'));
			return false;
		});

		function delcheck(){
			$("#delchecked").unbind();
			$("#delchecked").click(
				function (e){
					var result = new Array();
					$("#xlist [name = ids[]]:checkbox").each(function () {
						if ($(this).is(":checked")){
							result.push($(this).attr("value"));
						}
					});							 
						

					$.showfloatdiv({
						txt:'确定删除？',
						wantclose:2,
						suredo:function(e){	
							$("#ids").attr('value',result);
							$("#delremindform").qiresub({
								curobj:$("#delchecked"),
								txt:'数据提交中,请稍后...',
								onsucc:function(result){
									$.hidediv(result);
									if(parseInt(result['rcode'])>0){
										pagegoo("{:zanpian_user_url('user/center/love',array('op'=>1))}");
										gethot("{:zanpian_user_url('user/center/getlove')}");
										$("#pids").html(result.dhtxt);
										$("#pids a").unbind();
										$("#pids a").click(function (e){
											$(this).parent('li').nextAll().removeClass('current');
											$(this).parent('li').prevAll().removeClass('current');
											$(this).parent('li').addClass('current');
											pagegoo($(this).attr('href'));
											return false;
										});

										$("#checkall").attr('checked',false);
									}
							}
							}).post({
								url:"{:zanpian_user_url('user/center/dellove')}"
								});
							$.closefloatdiv();
							return false;
						}
					});
			});
		}
		delcheck();
	</script>
</div>
<!-- // maxBox End -->
</div>
<!-- // wrap End -->
<!-- // footer end -->
{include file="footer"/}
</body>
</html>